#!/bin/sh

root_path=`dirname "$0"`
cd $root_path
root_path=$PWD
service_name=$(basename $PWD)

python_bin_path=$root_path/python3/bin
export PATH=$python_bin_path:$PATH

echo "path $root_path"
echo "start $service_name"


PIDS=$(ps ax | grep -i python | grep $service_name | grep -v grep | awk '{print $1}')
if [ "$PIDS" ]; then
  echo $service_name started pid:$PIDS
else
  nohup python3 main.py $service_name >/dev/null 2>&1 &
  sleep 3
  PIDS=$(ps ax | grep -i java | grep $service_name | grep -v grep | awk '{print $1}')
  if [ "$PIDS" ]; then
    echo $service_name start success pid:$PIDS
  fi
fi

